package com.jingtai;

/**
 * 静态方法属于这个类而不是这个类的对象；
 * 调用静态方法的时候不需要创建这个类的对象；
 * 静态方法可以访问静态变量。
 */
public class StaticMethod {
    String name;
    int age;
    static String school = "郑州大学";


    public StaticMethod(String name, int age) {
        this.name = name;
        this.age = age;
    }

    static void change(StaticMethod staticMethod) {
        school = "河南大学";
    }

    void out(){
        System.out.println(name + " " + age + " " + school);
    }

    public static void main(String[] args) {
        StaticMethod s1 = new StaticMethod("zxt",18);
        StaticMethod s2 = new StaticMethod("zxt",18);

        s1.out();
        change(s2);
        s2.out();

    }

}
